﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TTEngine
{
    public class Key : MapObject
    {
        //constructor
        public Key()
            : base()
        {
            CanTake = true;
            UnitWeight = 0.1f;
            CanCollapse = false;
            Difficulty = 3;
        }

        //clone
        public override MapObject Clone()
        {
            return new Key();
        }

        //set code by difficulty
        public int Difficulty
        {
            get
            {
                return _difficulty;
            }
            set
            {
                _difficulty = value;
                string s = "";
                for (int n = 0; n < Difficulty; n++)
                {
                    char c = (char)(Globals.RandomIntFromTo(0, 25) + 'A');
                    s += c;
                }
                _code = s;
            }
        }

        //set difficulty by code
        public string Code
        {
            get
            {
                return _code;
            }
            set
            {
                _code = value;
                _difficulty = _code.Length;
            }
        }

        //private members
        private int _difficulty;
        private string _code;
    }
}
